﻿using System.Text;
using PgBirdie.Core.Model.Database.AccessControl;
using PgBirdie.Core.Model.Database.Structure;
using PgBirdie.Core.Model.Database.Structure.Constraint;
using PgBirdie.Core.Model.Database.Structure.Index;

namespace PgBirdie.Core.Service.DbObject
{
    public interface IDbObjectToSqlService
    {
        string GetSchemaName(PgDbObject table);

        // Database
        string CreateDatabase(PgDatabase db);

        // Schemas
        string CreateSchema(PgSchema schema);
        string DropSchema(PgSchema schema);

        // Tables
        string CreateTable(PgTable table);
        string DropTable(PgTable table);

        // Sequences
        string CreateSequence(PgSequence sequence);
        string AssociateTableColumnWithSequence(PgColumn column);

        // Indexes
        string CreateIndex(PgIndex index);
        string AlterIndex(PgIndex source, PgIndex target);
        string DropIndex(PgIndex index);

        // Columns
        string AddColumn(PgColumn column);
        string AlterColumn(PgColumn source, PgColumn target);
        string DropColumn(PgColumn column);

        // Constraints
        string AddConstraint(PgConstraintBase constraint);
        string DropConstraint(PgConstraintBase constraint);
        string AddPrimaryKey(PgPrimaryKey key);
        string AddUniqueKey(PgUniqueKey key);
        string AddForeignKey(PgForeignKey key);
        string AddCheck(PgCheck check);

        // Owner
        string SetOwner(PgOwner owner);

        // Privilege
        string SetPrivilege(PgPrivilege privilege);        
    }
}